# encoding: utf-8

import webbrowser, re

def main(env):
	rex = re.compile(env["static"]["cwBrowse_urlPattern"])
	for string in env["context"]["selection"].split():
		encodedString = repr(string.encode('utf8')).replace(r"\x","%")
		for match in rex.finditer(encodedString):
			webbrowser.open(match.group(0))
	return [("moveCursor",0)]
